﻿// ==UserScript==
// @name         google-tasks-backup
// @namespace    https://user-web.googlecode.com/
// @version      7
// @description  backup google tasks
// @grant        none
// @match        https://mail.google.com/tasks/canvas?pli=1
// @copyright    2010+, james_zerty
// ==/UserScript==

console.log("[google-tasks-backup] started");

try {

    var b = document.getElementsByClassName("Yb")[0];
    console.log("[google-tasks-backup] b=" + b);

    b.onclick = function () {
        console.log("[google-tasks-backup] b clicked");
    }

    var w = window.open("", "", "");
    console.log("[google-tasks-backup] w=" + w);
    console.log("[google-tasks-backup] w.document=" + w.document);
    var lists = [];

    /*window.setInterval(function(){
		
    console.log("google-tasks-backup interval");
		
    var listName = document.getElementsByTagName("IFRAME")[0].contentWindow.document.getElementById(":1.lt").innerText;
		
    if (lists[listName] == null){    
    //debugger;
    lists[listName] = true;
    w.document.write("<p>" + listName + "</p><ul>");
    var tasks = document.getElementsByTagName("IFRAME")[0].contentWindow.document.getElementsByClassName("d");
		
    for (var i = 0; i < tasks.length; i++){
    console.log(tasks[i].innerText);
    w.document.write("<li>" + tasks[i].innerText + "</li>");
    }
    w.document.write("</ul>");
    }
    console.log("google-tasks-backup interval over");
    }, 1000);*/
}
catch (ex) {
    console.log("[google-tasks-backup] error: " + ex.message);
}

// var tasks = document.getElementsByTagName("IFRAME")[0].contentWindow.document.getElementsByClassName("d")
// for (var i in tasks) { console.log(tasks[i].innerText); }